# coding:utf-8
# @Time    : 2021/11/29 17:38
# @Author  : Martin

from page_object.base import PageItemsCoupon
from util.read_file import get_approve_data


class OnlineNoShopCoupon(PageItemsCoupon):
    _base_url = "/nspas-web-in/processRoleFilter.do?businessTemplateId=NSOA23340&comType=1"

    business_code = None

    @staticmethod
    def get_approve_head_create():
        """
        获取总部新建审批流账号数据
        :return:
        """
        return get_approve_data('online_noshop_coupon', 'head', 'create')

    def input_coupon_price(self, balance):
        """
        输入券面值
        :param balance:
        :return:
        """
        self.input('name', 'noShopOnlineRule.couponsPrice', balance)

    def input_act_count(self, txt=None):
        """
        活动总次数
        :param txt:
        :return:
        """
        if txt:
            self.input('name', 'type6_activityTotal', txt)

    def go_to_approve(self):
        # 点击资源框确认
        self.click('xpath', '//input[@onclick="resourceConfirmOk();"]')
        self.wait(1)
        # 进入风控iframe
        self.switch_frame('child')
        self.wait(1)
        # 第一次点击确定
        # self.click('css selector', '.ux-btn-primary')
        self.js_click('.ux-btn.ux-btn-primary')
        # 第二次点击确定
        # self.click('css selector', '.footer-btn.ux-btn.ux-btn-primary')
        self.js_click('.footer-btn.ux-btn.ux-btn-primary')
        # 切回主体页面
        self.switch_default()
        # 点击资源管控确认按钮
        self.click('id', 'comfireBtn')


if __name__ == '__main__':
    pass
